package com.jiangyg.mall.coupon.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.coupon.dao.SpuBoundsDao;
import com.jiangyg.mall.coupon.dto.SpuBoundsDTO;
import com.jiangyg.mall.coupon.entity.SpuBounds;
import com.jiangyg.mall.coupon.vo.SpuBoundsVO;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SpuBoundsServiceImpl extends BaseServiceImpl<SpuBoundsDao, SpuBounds> implements SpuBoundsService {

    @Autowired
    public SpuBoundsServiceImpl(SpuBoundsDao spuBoundsDao) {
        super(spuBoundsDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<SpuBoundsVO> selectPagination(Pagination<SpuBoundsVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, SpuBoundsVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(SpuBoundsDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public SpuBoundsVO selectById(Long spuBoundsId) throws Exception {
        return this.executeSelectById(spuBoundsId, SpuBoundsVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> spuBoundsIds) {
        return this.baseMapper.deleteBatchIds(spuBoundsIds) > 0;
    }

}
